package com.gec.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.ITripItineraryOrder;
import com.gec.model.system.ITripService;
import com.gec.model.system.ITripServiceOrder;
import com.gec.model.system.ITripSightsOrder;
import com.gec.model.vo.ITripSightsOrderVo;
import com.gec.system.mapper.ITripSightsOrderMapper;
import com.gec.system.service.ITripSightsOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dafei
 * @since 2024-01-24
 */
@Service
public class ITripSightsOrderServiceImpl extends ServiceImpl<ITripSightsOrderMapper, ITripSightsOrder> implements ITripSightsOrderService {

    @Override
    public IPage<ITripSightsOrder> selectPage(IPage<ITripSightsOrder> p1, ITripSightsOrderVo iTripSightsOrderVo) {
        IPage<ITripSightsOrder> iPage = this.baseMapper.selectPage(p1,iTripSightsOrderVo,null) ;
        return iPage;
    }

    @Override
    public void updateIsPaid(Long id, Integer isPaid) {
        ITripSightsOrder it = baseMapper.selectById(id);
        it.setIsPaid(isPaid);
        baseMapper.update(it,null);
    }

    @Override
    public List<ITripSightsOrder> getByIsPaid(Long isPaid) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("isPaid",isPaid);//相当于where name=1
        List<ITripSightsOrder> list = baseMapper.selectList(wrapper);
        return list;
    }

    @Override
    public List<ITripSightsOrder> getByUserId(Long id) {
        List<ITripSightsOrder> list = baseMapper.getAllByUserId(id);
        return list;
    }
}
